package com.ljfiction.book.adapter;

import android.graphics.Color;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljfiction.book.Baner.PepperhavestBean;
import com.ljfiction.book.R;
import com.ljfiction.book.tools.ScreenUtils;
import com.ljfiction.book.tools.TimeTool;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Android on 2017/9/26.
 */

public class PeppeerhavestAdapter extends BaseQuickAdapter<PepperhavestBean.DataBean.ListBean, BaseViewHolder> {
    public PeppeerhavestAdapter(@LayoutRes int layoutResId, @Nullable List<PepperhavestBean.DataBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PepperhavestBean.DataBean.ListBean item) {
        AutoUtils.autoSize(helper.itemView);
        if ((helper.getLayoutPosition()) % 4 == 0) {
            helper.setBackgroundRes(R.id.leftview_pepperitem, R.drawable.shape_peperleft);
        } else if ((helper.getLayoutPosition()) % 4 == 1) {
            helper.setBackgroundRes(R.id.leftview_pepperitem, R.drawable.shape_peperlsft2);
        } else if ((helper.getLayoutPosition()) % 4 == 2) {
            helper.setBackgroundRes(R.id.leftview_pepperitem, R.drawable.shape_peperlsft3);
        } else if ((helper.getLayoutPosition()) % 4 == 3) {
            helper.setBackgroundRes(R.id.leftview_pepperitem, R.drawable.shape_peperlsft4);
        }
        helper.setText(R.id.persunusername_pepper, item.getPseudonym())
                .setText(R.id.time_pepper, TimeTool.getTimeByLong(item.getGiveDateTime()))
                .setText(R.id.booktitle_pepper, item.getBookName())
                .setText(R.id.liuyan_pepper, item.getArewardContent())
                .setText(R.id.num_pepper, String.valueOf(item.getSpicyiTicketCount()));
        Glide.with(mContext).load(item.getUserHeadPortraitURL()).override(ScreenUtils.getNum(mContext,38), ScreenUtils.getNum(mContext,38)).into((ImageView) helper.getView(R.id.personimage_pepperhavest));
        if (item.getRecoverystate()==0){
            helper.addOnClickListener(R.id.reply_pepper);
        }else {
            helper.setText(R.id.reply_pepper,"已回复").setTextColor(R.id.reply_pepper, Color.parseColor("#999999"));
        }

    }
}
